import { defHttp } from '/@/utils/http/axios';
import { PageResult } from '@/api/model/pageResult';
import { ContentTypeEnum } from '@/enums/httpEnum';
import { QueryMarketingMemberVo } from '@/api/promotions/member/modal/queryMarketingMemberVo';
import { QueryMarketingMemberBo } from '@/api/promotions/member/modal/queryMarketingMemberBo';
import { GetMarketingMemberBo } from '@/api/promotions/member/modal/getMarketingMemberBo';
import { CreateMarketingMemberVo } from '@/api/promotions/member/modal/createMarketingMemberVo';
import { UpdateMarketingMemberVo } from '@/api/promotions/member/modal/updateMarketingMemberVo';

const baseUrl = '/promo/member/day';
const region = 'cloud-api';

/**
 * 查询列表
 * @param params
 * @returns {Promise}
 */
export function query(params: QueryMarketingMemberVo): Promise<PageResult<QueryMarketingMemberBo>> {
  return defHttp.get<PageResult<QueryMarketingMemberBo>>(
    {
      url: baseUrl + '/query',
      params: params,
    },
    {
      region,
    },
  );
}

/**
 * 根据ID查询
 * @param id
 * @returns {Promise}
 */
export function get(id: String): Promise<GetMarketingMemberBo> {
  return defHttp.get<GetMarketingMemberBo>(
    {
      url: baseUrl,
      params: {
        id,
      },
    },
    {
      region,
    },
  );
}

/**
 * 新增
 * @param params
 * @returns {Promise}
 */
export function create(params: CreateMarketingMemberVo): Promise<void> {
  return defHttp.post<void>(
    {
      url: baseUrl,
      data: params,
    },
    {
      contentType: ContentTypeEnum.JSON,
      region,
    },
  );
}

/**
 * 修改
 * @param params
 * @returns {Promise}
 */
export function update(params: UpdateMarketingMemberVo): Promise<void> {
  return defHttp.put<void>(
    {
      url: baseUrl,
      data: params,
    },
    {
      contentType: ContentTypeEnum.JSON,
      region,
    },
  );
}
